package com.content.model
{	
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;

	public class TickProxy extends Proxy implements IProxy
	{
		public static const NAME:String						= 'TickProxy';
		
		public static const TIMEUP:String					= NAME + "-" + 'Timeup';
		
		private var _timer:Timer;
		private var _noteName:String;
		
		public function TickProxy()
		{
			super( NAME, new Object() );
			
			_timer = new Timer(50);
			_timer.addEventListener(TimerEvent.TIMER, onTimer);
		}
		
		public function SetTick(duration:uint, noteName:String):void{
			if(_timer.running) _timer.stop();
			
			_timer.delay = duration;
			_noteName = noteName;
			_timer.start();
		}
		
		
		/* Event Handler
		 * ------------------------------------------------------ */
		private function onTimer(evt:TimerEvent):void{
			_timer.stop()
			sendNotification( _noteName );
		}
		
		/*public function get vo():Object
		{
			return data as Object;
		}*/
	}
}